/***************************************************************************
 $ @Description: 
 $ @Author: NavyPeng
 $ @Date: 2024-04-08 09:25:24
 $ @LastEditTime: 2024-04-19 15:05:29
 $ @LastEditors: NavyPeng
 ***************************************************************************/
#include "Ctrl.h"

#if FactoryMethodPattern_

class LeiFeng {
public:
	void Sweep() {
		printf("扫地\r\n");
	}	
	void Wash() {
		printf("洗衣\r\n");
	}	
	void BuyRice() {
		printf("买米\r\n");
	}
};



class Undergraduate : public LeiFeng
{

};

class Volunteer : public LeiFeng
{

};

class IFactory {
public:
	virtual ~IFactory() {}
	virtual LeiFeng* CreateLeiFeng() = 0;
};

class UndergraduateFactory : public IFactory {
public:
	LeiFeng* CreateLeiFeng() override {
		return new Undergraduate();
	}
};

class VolunteerFactory : public IFactory {
public:
	LeiFeng* CreateLeiFeng() override {
		return new Volunteer();
	}
};

int main(void) {
	IFactory* factory = new UndergraduateFactory();
	LeiFeng* student = factory->CreateLeiFeng();
	student->BuyRice();
	student->Sweep();
	student->Wash();
	delete student;
	delete factory;
	IFactory* factory2 = new VolunteerFactory();
	LeiFeng* volunteer = factory2->CreateLeiFeng();
	volunteer->BuyRice();
	volunteer->Sweep();
	volunteer->Wash();
	delete volunteer;
	delete factory2;
}	


#endif